<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>异步加载图片</title>
</head>
<body>
    <h1>异步加载图片</h1>
    <script>
        function loadImgAsync(url) {
            return new Promise((resolve, reject) => {
                let img = new Image();
                img.onload = () => {
                    resolve(img);
                }
                img.onerror = (err) => {
                    reject(err);
                }
                img.src = url;
            });
        }

        const url = 'http://www.cdzfgjj.gov.cn/upload/CMScdgjj/201612/20161230mbjv5h3dmb.jpg';

        loadImgAsync(url).then(img => {
            document.body.appendChild(img);
        });
    </script>
</body>
</html>